﻿using BLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AdminController : ControllerBase
    {
        AdminBll bll;
        public AdminController(AdminBll bll)
        {
            this.bll = bll;
        }
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public int Adminadd(Admin admin)
        {
            try
            {
                return bll.Adminadd(admin);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult login(string username, string password)
        {
            try
            {
                var info = bll.login(username, password);
                return Ok(new
                {
                    data=info
                });

            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
